package cn.cloudplug.friendsrecommend;

import java.util.ArrayList;
import java.util.List;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.util.Log;
import android.view.Gravity;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.RelativeLayout.LayoutParams;
import android.widget.TextView;
import android.widget.Toast;
import cn.cloudplug.friendsrecommend.R;
import cn.cloudplug.friendsrecommend.util.AddView;
import cn.cloudplug.friendsrecommend.util.AddView.Type;

public class PersnalSignProInfoActivity extends Activity implements OnClickListener{
	private LinearLayout ll;
	private List<View> list;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_sign_personal_profession_info);
		setView();
		addView();
	}

	private void addView() {
		int[] views={1,2,1,2,1,2,1,2,1,21,2,1,2,0};
		list=new ArrayList<View>();
		for(int i:views){
			switch (i) {
			case 0:
				View btn=new AddView(this).createView(Type.BUTTON,"下一步",0);
				list.add(btn);
				break;
			case 1:
				View tv=new AddView(this).createView(Type.TEXTVIEW,"姓名",0);
				list.add(tv);
				break;
			case 2:
				View ed=new AddView(this).createView(Type.EDITTEXT,"姓名",0);
				list.add(ed);
				break;
			}
		}
		for(View v:list){
			v.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View v) {
					Toast.makeText(PersnalSignProInfoActivity.this, "v=="+v.getId(), 0).show();
				}
			});
			ll.addView(v);
		}
	}

	private void setView() {
		findViewById(R.id.title).findViewById(R.id.iv_home).setOnClickListener(this);
		ll=(LinearLayout) findViewById(R.id.scrollview).findViewById(R.id.linearlayout);
	}

	@Override
	public void onClick(View v) {
		int i=list.get(list.size()-1).getId();
		switch (v.getId()) {
		case R.id.iv_home:
			startActivity(MainActivity.class);
			break;
		}
		
	}
	private void startActivity(Class<?> clz) {
		startActivity(new Intent(this,clz));
	}
}
